<%-- 
    Document   : TCubeLoginStatus
    Created on : Sep 27, 2011, 8:01:21 AM
    Author     : Belinda
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList, BusinessLogic.Constants, EntityState.TCubeAccountState" %>
<!DOCTYPE html>
<html>
    <!-- InstanceBegin template="../TransactWeb/Templates/FdSageAdmin.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <!-- InstanceBeginEditable name="doctitle" -->
        <title>TCube Login Status</title>
        <script language="javascript" type="text/javascript" src="../TransactWeb/js/jquery-1.6.4.min.js"></script>
        <script language="javascript" type="text/javascript" src="../TransactWeb/js/jquery.form.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/fieldsetCollapse.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/tcubmenu.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/accordion.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/scroller.js"></script>
        <script type="text/javascript" src="../TransactWeb/js/Utilities.js"></script>

        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/gridsys.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/reset1.css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcube.css" />
        <link href="../TransactWeb/css/gridsys.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="../TransactWeb/css/tcubaccd.css" />
        <script type="text/javascript">
            // Check Session to show relevant menus
            // Be sure to import Utilities.js in the script file	and declare partnerMenu as a servelet element
            window.onload = showPage('tcubeMenu', 'leftnav');

            // If not logged in, use :
            <%
                       ArrayList data = (ArrayList) request.getAttribute("data");
                       int result = ((Integer) data.get(0)).intValue();
                       if (result == Constants.STATUS_NEW_SESSION || result == Constants.STATUS_WRONG_PASSWORD || result == Constants.STATUS_USER_INACTIVATED || result == Constants.STATUS_ACCOUNT_BANNED) {
            %> 
                window.onload = showPage('topMenutcube', 'topmenu');
            <% } else {%>
                //IF logged in use : 
                window.onload = showPage('topMenulogouttcube', 'topmenu');
           
            <% }%>
               
                //welcome msg
                window.onload = showPage('welcomeMenutcube','welcome');

                //footer
                window.onload = showPage('tcubeFooter','footer');
        </script>
    </head>
    <body>
        <div class="container_12">
            <!-- Header Nav -->
            <div class="grid_3"><img src="../TransactWeb/img/reservation/foodsglogo.png" width="146" height="178" /></div>
            <div class="grid_9 nav">
                <div id="topmenu"></div>
            </div>

            <div class="grid_12">
                <hr size="3" color="#CC6600" />
            </div>
            <!-- Welcome Message -->
            <!--<div class="grid_12 welcome">Welcome User!</div>-->
            <!-- End Welcome Message-->

            <!-- End of Header Nav -->
            <!-- Content -->
            <!-----------------------------------------------------------------------------------------------------------------> 

            <%

                if (result == Constants.STATUS_NEW_SESSION || result == Constants.STATUS_WRONG_PASSWORD || result == Constants.STATUS_USER_INACTIVATED || result == Constants.STATUS_ACCOUNT_BANNED) {
            %>

            <script type="text/javascript">
                $(document).ready(function () {
                    var tz = jstz.determine_timezone();
                    var jsTz = tz.name();
                    document.TCubeLogin.timezone.value = jsTz;
                });
            </script>
            <div class="grid_8 push_3 content">
                <!--Login -->
                <form action="https://localhost:8181/portal/internal/TCubeLoginStatus" name="TCubeLogin" method="post">
                    <input type="hidden" id="currentURL" name="currentURL" />
                    <input type="hidden" name="timezone" id="timezone"/>
                    <table width="600" border="0" style="padding:10px 0px 10px 0px;">
                        <tr>
                            <td>
                                Username :
                            </td>
                            <td>
                                <input name="username" id="username" type="text" /> &nbsp;&nbsp; 
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Password :
                            </td>
                            <td>
                                <input name="password" id="password" type="password" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input name="login" type="submit" value="Login" />
                            </td>
                        </tr>

                    </table>
                </form>

            </div>
            <%
                if (result == Constants.STATUS_NEW_SESSION) {
            %>
            <div class="grid_8 push_3 content">

                <font color ="black">Please Register An Account Before You Login.</font>
            </div>
            <%        } else if (result == Constants.STATUS_WRONG_PASSWORD) {
            %>
            <div class="grid_8 push_3 content">
                <font color ="black">You Entered The Wrong Username or Password.</font>
            </div>
            <%        } else if (result == Constants.STATUS_USER_INACTIVATED) {
            %>
            <div class="grid_8 push_3 content"><font color ="black">
                You are not allowed to login at the moment.<br/>
                We have sent an activation email to your Email account. <br/>
                Please proceed to activate your account first.<br/>
                </font>
            </div>
            <%        } else {
            %>
            <div class="grid_8 push_3 content">
                <font color ="black">Your account has been banned.</font>
            </div>
            <%                }
            } else {
                TCubeAccountState tas = (TCubeAccountState) session.getAttribute("staff");
            %>
            <!-- Welcome Message -->
            <div class="grid_12 welcome">Welcome <%= tas.getUsername()%>!<div id="welcome"></div></div>
            <!-- End Welcome Message-->
            <script type="text/javascript">
                $(document).ready(function() {
                    setTimeout(window.location.replace("http://localhost:8080/portal/internal/TCubeHome"), 4000);
                });
            </script>
            <div class="grid_4">
                <div id="leftnav"></div>
            </div>
            <div class="grid_8 content"></div>

            <%
                }
            %>
            <!-- End Content -->
            <!-- Footer -->
            <div class="grid_12 footer">
                <div id="footer"></div>
                
            </div>
            <!-- End Footer-->
        </div>
    </body>
</html>
